package com.business_clean.ui.adapter.camera;

import android.graphics.Color;
import android.text.TextUtils;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.business_clean.R;
import com.business_clean.app.weight.CustomAvatarView;
import com.business_clean.data.mode.camera.LeaderClockUserListEntity;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

public class LeaderItemAdapter extends BaseQuickAdapter<LeaderClockUserListEntity, BaseViewHolder> {
    public LeaderItemAdapter() {
        super(R.layout.item_leader_item);
        addChildClickViewIds(R.id.tv_item_leader_item_jiaban, R.id.tv_item_leader_item_status);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder holder, LeaderClockUserListEntity item) {
        LinearLayout layout = holder.getView(R.id.ll_item_leader_layout);
        if (!"10".equals(item.getStatus())) {//只有 不等于 10的才显示， 因为 10是跟后端协定的规则
            layout.setVisibility(View.VISIBLE);
            holder.setText(R.id.tv_item_leader_item_name, item.getUser_name())
//                    .setText(R.id.tv_item_leader_item_address, item.getProject_name())
                    .setText(R.id.tv_item_leader_item_job_name, item.getJob_name())
                    .setText(R.id.tv_item_leader_item_status, item.getStatus_name());

            CustomAvatarView customAvatarView = holder.getView(R.id.iv_item_leader_item_custom);
            customAvatarView.setAvatar(item.getAvatar(), item.getUser_name());

            if (!TextUtils.isEmpty(item.getStatus_name())) {
                holder.setText(R.id.tv_item_leader_item_status, item.getStatus_name());
            } else {
                holder.setText(R.id.tv_item_leader_item_status, "出勤");
            }

            TextView tvStatus = holder.getView(R.id.tv_item_leader_item_status);
            //处理下颜色 status:1休假 2正常出勤 3缺卡 4旷工 5休息 6加班
            switch (item.getStatus()) {
                case "1":
                    tvStatus.setTextColor(Color.parseColor("#A671CF"));
                    break;
                case "0":
                case "2":
                    tvStatus.setTextColor(Color.parseColor("#09BE89"));
                    break;
                case "3":
                    tvStatus.setTextColor(Color.parseColor("#FF801A"));
                    break;
                case "4":
                    tvStatus.setTextColor(Color.parseColor("#FF4040"));
                    break;
                case "5":
                    tvStatus.setTextColor(Color.parseColor("#000000"));
                    break;
                case "6":
                    tvStatus.setTextColor(Color.parseColor("#1890FF"));
                    break;
            }
            //针对删除的按钮 处理显示不显示
            if ("6".equals(item.getStatus())) {
                holder.getView(R.id.tv_item_leader_item_jiaban).setVisibility(View.VISIBLE);
            } else {
                holder.getView(R.id.tv_item_leader_item_jiaban).setVisibility(View.GONE);
            }
        } else {
            layout.setVisibility(View.GONE);
        }

    }
}
